import java.util.Random;
import java.util.Scanner;

/**
 * @Author 宁铂
 * @Date 2021/7/6 15:20
 * @Version 1.0
 */
public class TestDoWhile {
    /** 通过do while 来完成猜数字游戏 */
    public static void main(String[] args) {

        int random = new Random().nextInt(100);

        do{
            System.out.println("请输入您猜的整数：");
            int input = new Scanner(System.in).nextInt();

            if(input>random){
                System.out.println("猜大了");
            }else if(input<random){
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了");
                break;
            }

        }while (true);
    }
}
